// { dg-do run { target c++11 } }
// { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
//
// Copyright (C) 2016-2022 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3.  If not see
// <http://www.gnu.org/licenses/>.

//  sph_legendre
//  Compare against values generated by the GNU Scientific Library.
//  The GSL can be found on the web: http://www.gnu.org/software/gsl/
#include <limits>
#include <tr1/cmath>
#if defined(__TEST_DEBUG)
#  include <iostream>
#  define VERIFY(A) \
  if (!(A)) \
    { \
      std::cout << "line " << __LINE__ \
	<< "  max_abs_frac = " << max_abs_frac \
	<< std::endl; \
    }
#else
#  include <testsuite_hooks.h>
#endif
#include <specfun_testcase.h>

// Test data for l=0, m=0.
// max(|f - f_GSL|): 0.0000000000000000 at index 0
// max(|f - f_GSL| / |f_GSL|): 0.0000000000000000
// mean(f - f_GSL): 0.0000000000000000
// variance(f - f_GSL): 0.0000000000000000
// stddev(f - f_GSL): 0.0000000000000000
const testcase_sph_legendre<double>
data001[21] =
{
  { 0.28209479177387814, 0, 0, 
	  0.0000000000000000, 0.0 },
  { 0.28209479177387814, 0, 0, 
	  0.15707963267948966, 0.0 },
  { 0.28209479177387814, 0, 0, 
	  0.31415926535897931, 0.0 },
  { 0.28209479177387814, 0, 0, 
	  0.47123889803846897, 0.0 },
  { 0.28209479177387814, 0, 0, 
	  0.62831853071795862, 0.0 },
  { 0.28209479177387814, 0, 0, 
	  0.78539816339744828, 0.0 },
  { 0.28209479177387814, 0, 0, 
	  0.94247779607693793, 0.0 },
  { 0.28209479177387814, 0, 0, 
	  1.0995574287564276, 0.0 },
  { 0.28209479177387814, 0, 0, 
	  1.2566370614359172, 0.0 },
  { 0.28209479177387814, 0, 0, 
	  1.4137166941154069, 0.0 },
  { 0.28209479177387814, 0, 0, 
	  1.5707963267948966, 0.0 },
  { 0.28209479177387814, 0, 0, 
	  1.7278759594743862, 0.0 },
  { 0.28209479177387814, 0, 0, 
	  1.8849555921538759, 0.0 },
  { 0.28209479177387814, 0, 0, 
	  2.0420352248333655, 0.0 },
  { 0.28209479177387814, 0, 0, 
	  2.1991148575128552, 0.0 },
  { 0.28209479177387814, 0, 0, 
	  2.3561944901923448, 0.0 },
  { 0.28209479177387814, 0, 0, 
	  2.5132741228718345, 0.0 },
  { 0.28209479177387814, 0, 0, 
	  2.6703537555513241, 0.0 },
  { 0.28209479177387814, 0, 0, 
	  2.8274333882308138, 0.0 },
  { 0.28209479177387814, 0, 0, 
	  2.9845130209103035, 0.0 },
  { 0.28209479177387814, 0, 0, 
	  3.1415926535897931, 0.0 },
};
const double toler001 = 2.5000000000000020e-13;

// Test data for l=1, m=0.
// max(|f - f_GSL|): 0.0000000000000000 at index 0
// max(|f - f_GSL| / |f_GSL|): 0.0000000000000000
// mean(f - f_GSL): 0.0000000000000000
// variance(f - f_GSL): 0.0000000000000000
// stddev(f - f_GSL): 0.0000000000000000
const testcase_sph_legendre<double>
data002[21] =
{
  { 0.48860251190291992, 1, 0, 
	  0.0000000000000000, 0.0 },
  { 0.48258700419201095, 1, 0, 
	  0.15707963267948966, 0.0 },
  { 0.46468860282345237, 1, 0, 
	  0.31415926535897931, 0.0 },
  { 0.43534802584032634, 1, 0, 
	  0.47123889803846897, 0.0 },
  { 0.39528773562374969, 1, 0, 
	  0.62831853071795862, 0.0 },
  { 0.34549414947133550, 1, 0, 
	  0.78539816339744828, 0.0 },
  { 0.28719335072959395, 1, 0, 
	  0.94247779607693793, 0.0 },
  { 0.22182089855280449, 1, 0, 
	  1.0995574287564276, 0.0 },
  { 0.15098647967228981, 1, 0, 
	  1.2566370614359172, 0.0 },
  { 0.076434272566846345, 1, 0, 
	  1.4137166941154069, 0.0 },
  { 2.9918275112863332e-17, 1, 0, 
	  1.5707963267948966, 0.0 },
  { -0.076434272566846290, 1, 0, 
	  1.7278759594743862, 0.0 },
  { -0.15098647967228976, 1, 0, 
	  1.8849555921538759, 0.0 },
  { -0.22182089855280446, 1, 0, 
	  2.0420352248333655, 0.0 },
  { -0.28719335072959384, 1, 0, 
	  2.1991148575128552, 0.0 },
  { -0.34549414947133544, 1, 0, 
	  2.3561944901923448, 0.0 },
  { -0.39528773562374975, 1, 0, 
	  2.5132741228718345, 0.0 },
  { -0.43534802584032628, 1, 0, 
	  2.6703537555513241, 0.0 },
  { -0.46468860282345231, 1, 0, 
	  2.8274333882308138, 0.0 },
  { -0.48258700419201095, 1, 0, 
	  2.9845130209103035, 0.0 },
  { -0.48860251190291992, 1, 0, 
	  3.1415926535897931, 0.0 },
};
const double toler002 = 2.5000000000000020e-13;

// Test data for l=1, m=1.
// max(|f - f_GSL|): 1.9984014443252818e-15 at index 9
// max(|f - f_GSL| / |f_GSL|): 5.9507621559271917e-15
// mean(f - f_GSL): 1.1981156807413147e-15
// variance(f - f_GSL): 7.5362762183006766e-32
// stddev(f - f_GSL): 2.7452278991553101e-16
const testcase_sph_legendre<double>
data003[21] =
{
  { 0.0000000000000000, 1, 1, 
	  0.0000000000000000, 0.0 },
  { -0.054047192447078167, 1, 1, 
	  0.15707963267948966, 0.0 },
  { -0.10676356364376091, 1, 1, 
	  0.31415926535897931, 0.0 },
  { -0.15685106157558129, 1, 1, 
	  0.47123889803846897, 0.0 },
  { -0.20307636581258248, 1, 1, 
	  0.62831853071795862, 0.0 },
  { -0.24430125595146007, 1, 1, 
	  0.78539816339744828, 0.0 },
  { -0.27951063837942880, 1, 1, 
	  0.94247779607693793, 0.0 },
  { -0.30783754124787122, 1, 1, 
	  1.0995574287564276, 0.0 },
  { -0.32858446219656556, 1, 1, 
	  1.2566370614359172, 0.0 },
  { -0.34124054317667202, 1, 1, 
	  1.4137166941154069, 0.0 },
  { -0.34549414947133567, 1, 1, 
	  1.5707963267948966, 0.0 },
  { -0.34124054317667202, 1, 1, 
	  1.7278759594743862, 0.0 },
  { -0.32858446219656556, 1, 1, 
	  1.8849555921538759, 0.0 },
  { -0.30783754124787127, 1, 1, 
	  2.0420352248333655, 0.0 },
  { -0.27951063837942880, 1, 1, 
	  2.1991148575128552, 0.0 },
  { -0.24430125595146013, 1, 1, 
	  2.3561944901923448, 0.0 },
  { -0.20307636581258243, 1, 1, 
	  2.5132741228718345, 0.0 },
  { -0.15685106157558140, 1, 1, 
	  2.6703537555513241, 0.0 },
  { -0.10676356364376104, 1, 1, 
	  2.8274333882308138, 0.0 },
  { -0.054047192447078167, 1, 1, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 1, 1, 
	  3.1415926535897931, 0.0 },
};
const double toler003 = 5.0000000000000039e-13;

// Test data for l=2, m=0.
// max(|f - f_GSL|): 1.1102230246251565e-16 at index 0
// max(|f - f_GSL| / |f_GSL|): 3.1667226501700652e-15
// mean(f - f_GSL): -3.0233752009881492e-17
// variance(f - f_GSL): 3.4265646892248527e-34
// stddev(f - f_GSL): 1.8510982386747748e-17
const testcase_sph_legendre<double>
data004[21] =
{
  { 0.63078313050504009, 2, 0, 
	  0.0000000000000000, 0.0 },
  { 0.60762858760316585, 2, 0, 
	  0.15707963267948966, 0.0 },
  { 0.54043148688396603, 2, 0, 
	  0.31415926535897931, 0.0 },
  { 0.43576954875556589, 2, 0, 
	  0.47123889803846897, 0.0 },
  { 0.30388781294457567, 2, 0, 
	  0.62831853071795862, 0.0 },
  { 0.15769578262626011, 2, 0, 
	  0.78539816339744828, 0.0 },
  { 0.011503752307944374, 2, 0, 
	  0.94247779607693793, 0.0 },
  { -0.12037798350304570, 2, 0, 
	  1.0995574287564276, 0.0 },
  { -0.22503992163144576, 2, 0, 
	  1.2566370614359172, 0.0 },
  { -0.29223702235064597, 2, 0, 
	  1.4137166941154069, 0.0 },
  { -0.31539156525252005, 2, 0, 
	  1.5707963267948966, 0.0 },
  { -0.29223702235064597, 2, 0, 
	  1.7278759594743862, 0.0 },
  { -0.22503992163144584, 2, 0, 
	  1.8849555921538759, 0.0 },
  { -0.12037798350304577, 2, 0, 
	  2.0420352248333655, 0.0 },
  { 0.011503752307944164, 2, 0, 
	  2.1991148575128552, 0.0 },
  { 0.15769578262625994, 2, 0, 
	  2.3561944901923448, 0.0 },
  { 0.30388781294457579, 2, 0, 
	  2.5132741228718345, 0.0 },
  { 0.43576954875556562, 2, 0, 
	  2.6703537555513241, 0.0 },
  { 0.54043148688396569, 2, 0, 
	  2.8274333882308138, 0.0 },
  { 0.60762858760316585, 2, 0, 
	  2.9845130209103035, 0.0 },
  { 0.63078313050504009, 2, 0, 
	  3.1415926535897931, 0.0 },
};
const double toler004 = 2.5000000000000020e-13;

// Test data for l=2, m=1.
// max(|f - f_GSL|): 2.2204460492503131e-15 at index 5
// max(|f - f_GSL| / |f_GSL|): 5.9294218689659490e-15
// mean(f - f_GSL): 6.6084703846736834e-19
// variance(f - f_GSL): 2.2927737433182295e-38
// stddev(f - f_GSL): 1.5141907882820546e-19
const testcase_sph_legendre<double>
data005[21] =
{
  { 0.0000000000000000, 2, 1, 
	  0.0000000000000000, 0.0 },
  { -0.11936529291378781, 2, 1, 
	  0.15707963267948966, 0.0 },
  { -0.22704627929027421, 2, 1, 
	  0.31415926535897931, 0.0 },
  { -0.31250239392538215, 2, 1, 
	  0.47123889803846897, 0.0 },
  { -0.36736859691086526, 2, 1, 
	  0.62831853071795862, 0.0 },
  { -0.38627420202318979, 2, 1, 
	  0.78539816339744828, 0.0 },
  { -0.36736859691086532, 2, 1, 
	  0.94247779607693793, 0.0 },
  { -0.31250239392538226, 2, 1, 
	  1.0995574287564276, 0.0 },
  { -0.22704627929027438, 2, 1, 
	  1.2566370614359172, 0.0 },
  { -0.11936529291378740, 2, 1, 
	  1.4137166941154069, 0.0 },
  { -4.7304946510089680e-17, 2, 1, 
	  1.5707963267948966, 0.0 },
  { 0.11936529291378731, 2, 1, 
	  1.7278759594743862, 0.0 },
  { 0.22704627929027429, 2, 1, 
	  1.8849555921538759, 0.0 },
  { 0.31250239392538226, 2, 1, 
	  2.0420352248333655, 0.0 },
  { 0.36736859691086521, 2, 1, 
	  2.1991148575128552, 0.0 },
  { 0.38627420202318979, 2, 1, 
	  2.3561944901923448, 0.0 },
  { 0.36736859691086526, 2, 1, 
	  2.5132741228718345, 0.0 },
  { 0.31250239392538232, 2, 1, 
	  2.6703537555513241, 0.0 },
  { 0.22704627929027449, 2, 1, 
	  2.8274333882308138, 0.0 },
  { 0.11936529291378781, 2, 1, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 2, 1, 
	  3.1415926535897931, 0.0 },
};
const double toler005 = 5.0000000000000039e-13;

// Test data for l=2, m=2.
// max(|f - f_GSL|): 2.2759572004815709e-15 at index 10
// max(|f - f_GSL| / |f_GSL|): 6.0197685443914339e-15
// mean(f - f_GSL): -1.0489294618073093e-15
// variance(f - f_GSL): 5.7763283331987012e-32
// stddev(f - f_GSL): 2.4033993287006430e-16
const testcase_sph_legendre<double>
data006[21] =
{
  { 0.0000000000000000, 2, 2, 
	  0.0000000000000000, 0.0 },
  { 0.0094528025561623485, 2, 2, 
	  0.15707963267948966, 0.0 },
  { 0.036885904048903732, 2, 2, 
	  0.31415926535897931, 0.0 },
  { 0.079613961366457681, 2, 2, 
	  0.47123889803846897, 0.0 },
  { 0.13345445455470126, 2, 2, 
	  0.62831853071795862, 0.0 },
  { 0.19313710101159490, 2, 2, 
	  0.78539816339744828, 0.0 },
  { 0.25281974746848851, 2, 2, 
	  0.94247779607693793, 0.0 },
  { 0.30666024065673209, 2, 2, 
	  1.0995574287564276, 0.0 },
  { 0.34938829797428600, 2, 2, 
	  1.2566370614359172, 0.0 },
  { 0.37682139946702753, 2, 2, 
	  1.4137166941154069, 0.0 },
  { 0.38627420202318985, 2, 2, 
	  1.5707963267948966, 0.0 },
  { 0.37682139946702753, 2, 2, 
	  1.7278759594743862, 0.0 },
  { 0.34938829797428606, 2, 2, 
	  1.8849555921538759, 0.0 },
  { 0.30666024065673214, 2, 2, 
	  2.0420352248333655, 0.0 },
  { 0.25281974746848856, 2, 2, 
	  2.1991148575128552, 0.0 },
  { 0.19313710101159498, 2, 2, 
	  2.3561944901923448, 0.0 },
  { 0.13345445455470123, 2, 2, 
	  2.5132741228718345, 0.0 },
  { 0.079613961366457764, 2, 2, 
	  2.6703537555513241, 0.0 },
  { 0.036885904048903809, 2, 2, 
	  2.8274333882308138, 0.0 },
  { 0.0094528025561623485, 2, 2, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 2, 2, 
	  3.1415926535897931, 0.0 },
};
const double toler006 = 5.0000000000000039e-13;

// Test data for l=5, m=0.
// max(|f - f_GSL|): 1.0547118733938987e-15 at index 18
// max(|f - f_GSL| / |f_GSL|): 2.9385557676213648e-15
// mean(f - f_GSL): -4.2955057500378082e-17
// variance(f - f_GSL): 9.6869690655191325e-35
// stddev(f - f_GSL): 9.8422401238331574e-18
const testcase_sph_legendre<double>
data007[21] =
{
  { 0.93560257962738880, 5, 0, 
	  0.0000000000000000, 0.0 },
  { 0.77014422942079852, 5, 0, 
	  0.15707963267948966, 0.0 },
  { 0.35892185032365348, 5, 0, 
	  0.31415926535897931, 0.0 },
  { -0.090214932090594294, 5, 0, 
	  0.47123889803846897, 0.0 },
  { -0.36214460396518905, 5, 0, 
	  0.62831853071795862, 0.0 },
  { -0.35145955579226906, 5, 0, 
	  0.78539816339744828, 0.0 },
  { -0.11441703594725193, 5, 0, 
	  0.94247779607693793, 0.0 },
  { 0.17248966720808107, 5, 0, 
	  1.0995574287564276, 0.0 },
  { 0.32128384287200523, 5, 0, 
	  1.2566370614359172, 0.0 },
  { 0.24377632246714948, 5, 0, 
	  1.4137166941154069, 0.0 },
  { 1.0741712853887687e-16, 5, 0, 
	  1.5707963267948966, 0.0 },
  { -0.24377632246714936, 5, 0, 
	  1.7278759594743862, 0.0 },
  { -0.32128384287200534, 5, 0, 
	  1.8849555921538759, 0.0 },
  { -0.17248966720808118, 5, 0, 
	  2.0420352248333655, 0.0 },
  { 0.11441703594725151, 5, 0, 
	  2.1991148575128552, 0.0 },
  { 0.35145955579226895, 5, 0, 
	  2.3561944901923448, 0.0 },
  { 0.36214460396518883, 5, 0, 
	  2.5132741228718345, 0.0 },
  { 0.090214932090594752, 5, 0, 
	  2.6703537555513241, 0.0 },
  { -0.35892185032365165, 5, 0, 
	  2.8274333882308138, 0.0 },
  { -0.77014422942079852, 5, 0, 
	  2.9845130209103035, 0.0 },
  { -0.93560257962738880, 5, 0, 
	  3.1415926535897931, 0.0 },
};
const double toler007 = 2.5000000000000020e-13;

// Test data for l=5, m=1.
// max(|f - f_GSL|): 3.3306690738754696e-15 at index 2
// max(|f - f_GSL| / |f_GSL|): 6.7265986294921411e-15
// mean(f - f_GSL): 6.3573485100559560e-16
// variance(f - f_GSL): 2.1218337041113107e-32
// stddev(f - f_GSL): 1.4566515383273072e-16
const testcase_sph_legendre<double>
data008[21] =
{
  { 0.0000000000000000, 5, 1, 
	  0.0000000000000000, 0.0 },
  { -0.36712373713318402, 5, 1, 
	  0.15707963267948966, 0.0 },
  { -0.54610329010534708, 5, 1, 
	  0.31415926535897931, 0.0 },
  { -0.45381991493631763, 5, 1, 
	  0.47123889803846897, 0.0 },
  { -0.15679720635769906, 5, 1, 
	  0.62831853071795862, 0.0 },
  { 0.16985499419838601, 5, 1, 
	  0.78539816339744828, 0.0 },
  { 0.34468004499725169, 5, 1, 
	  0.94247779607693793, 0.0 },
  { 0.28349471119605985, 5, 1, 
	  1.0995574287564276, 0.0 },
  { 0.044286619339675815, 5, 1, 
	  1.2566370614359172, 0.0 },
  { -0.21193784177193470, 5, 1, 
	  1.4137166941154069, 0.0 },
  { -0.32028164857621527, 5, 1, 
	  1.5707963267948966, 0.0 },
  { -0.21193784177193487, 5, 1, 
	  1.7278759594743862, 0.0 },
  { 0.044286619339675592, 5, 1, 
	  1.8849555921538759, 0.0 },
  { 0.28349471119605973, 5, 1, 
	  2.0420352248333655, 0.0 },
  { 0.34468004499725174, 5, 1, 
	  2.1991148575128552, 0.0 },
  { 0.16985499419838640, 5, 1, 
	  2.3561944901923448, 0.0 },
  { -0.15679720635769961, 5, 1, 
	  2.5132741228718345, 0.0 },
  { -0.45381991493631768, 5, 1, 
	  2.6703537555513241, 0.0 },
  { -0.54610329010534753, 5, 1, 
	  2.8274333882308138, 0.0 },
  { -0.36712373713318402, 5, 1, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 5, 1, 
	  3.1415926535897931, 0.0 },
};
const double toler008 = 5.0000000000000039e-13;

// Test data for l=5, m=2.
// max(|f - f_GSL|): 2.6645352591003757e-15 at index 4
// max(|f - f_GSL| / |f_GSL|): 6.1144597746666128e-15
// mean(f - f_GSL): -4.3615904538845404e-17
// variance(f - f_GSL): 9.9873224258937960e-35
// stddev(f - f_GSL): 9.9936592026613535e-18
const testcase_sph_legendre<double>
data009[21] =
{
  { 0.0000000000000000, 5, 2, 
	  0.0000000000000000, 0.0 },
  { 0.078919441745546909, 5, 2, 
	  0.15707963267948966, 0.0 },
  { 0.26373799140437948, 5, 2, 
	  0.31415926535897931, 0.0 },
  { 0.43002359842080096, 5, 2, 
	  0.47123889803846897, 0.0 },
  { 0.45642486439050983, 5, 2, 
	  0.62831853071795862, 0.0 },
  { 0.29959604906083298, 5, 2, 
	  0.78539816339744828, 0.0 },
  { 0.023781239849532509, 5, 2, 
	  0.94247779607693793, 0.0 },
  { -0.23313989334673826, 5, 2, 
	  1.0995574287564276, 0.0 },
  { -0.33799912776303714, 5, 2, 
	  1.2566370614359172, 0.0 },
  { -0.23964508489529746, 5, 2, 
	  1.4137166941154069, 0.0 },
  { -1.0377480524338157e-16, 5, 2, 
	  1.5707963267948966, 0.0 },
  { 0.23964508489529732, 5, 2, 
	  1.7278759594743862, 0.0 },
  { 0.33799912776303714, 5, 2, 
	  1.8849555921538759, 0.0 },
  { 0.23313989334673843, 5, 2, 
	  2.0420352248333655, 0.0 },
  { -0.023781239849531916, 5, 2, 
	  2.1991148575128552, 0.0 },
  { -0.29959604906083270, 5, 2, 
	  2.3561944901923448, 0.0 },
  { -0.45642486439050983, 5, 2, 
	  2.5132741228718345, 0.0 },
  { -0.43002359842080118, 5, 2, 
	  2.6703537555513241, 0.0 },
  { -0.26373799140437981, 5, 2, 
	  2.8274333882308138, 0.0 },
  { -0.078919441745546909, 5, 2, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 5, 2, 
	  3.1415926535897931, 0.0 },
};
const double toler009 = 5.0000000000000039e-13;

// Test data for l=5, m=5.
// max(|f - f_GSL|): 2.3869795029440866e-15 at index 10
// max(|f - f_GSL| / |f_GSL|): 5.4714279627676651e-15
// mean(f - f_GSL): 7.7966720691209837e-16
// variance(f - f_GSL): 3.1913750060540917e-32
// stddev(f - f_GSL): 1.7864419962747438e-16
const testcase_sph_legendre<double>
data010[21] =
{
  { 0.0000000000000000, 5, 5, 
	  0.0000000000000000, 0.0 },
  { -4.3481439097910151e-05, 5, 5, 
	  0.15707963267948966, 0.0 },
  { -0.0013078367086431740, 5, 5, 
	  0.31415926535897931, 0.0 },
  { -0.0089510818191922761, 5, 5, 
	  0.47123889803846897, 0.0 },
  { -0.032563803777573910, 5, 5, 
	  0.62831853071795862, 0.0 },
  { -0.082047757105021241, 5, 5, 
	  0.78539816339744828, 0.0 },
  { -0.16085328164143806, 5, 5, 
	  0.94247779607693793, 0.0 },
  { -0.26064303436645381, 5, 5, 
	  1.0995574287564276, 0.0 },
  { -0.36113811790820571, 5, 5, 
	  1.2566370614359172, 0.0 },
  { -0.43625592459446139, 5, 5, 
	  1.4137166941154069, 0.0 },
  { -0.46413220344085809, 5, 5, 
	  1.5707963267948966, 0.0 },
  { -0.43625592459446144, 5, 5, 
	  1.7278759594743862, 0.0 },
  { -0.36113811790820577, 5, 5, 
	  1.8849555921538759, 0.0 },
  { -0.26064303436645381, 5, 5, 
	  2.0420352248333655, 0.0 },
  { -0.16085328164143822, 5, 5, 
	  2.1991148575128552, 0.0 },
  { -0.082047757105021310, 5, 5, 
	  2.3561944901923448, 0.0 },
  { -0.032563803777573896, 5, 5, 
	  2.5132741228718345, 0.0 },
  { -0.0089510818191923004, 5, 5, 
	  2.6703537555513241, 0.0 },
  { -0.0013078367086431812, 5, 5, 
	  2.8274333882308138, 0.0 },
  { -4.3481439097910151e-05, 5, 5, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 5, 5, 
	  3.1415926535897931, 0.0 },
};
const double toler010 = 5.0000000000000039e-13;

// Test data for l=10, m=0.
// max(|f - f_GSL|): 9.9920072216264089e-16 at index 18
// max(|f - f_GSL| / |f_GSL|): 4.3176588435352323e-15
// mean(f - f_GSL): 5.6171998269725183e-18
// variance(f - f_GSL): 1.6565290295473546e-36
// stddev(f - f_GSL): 1.2870621700397205e-18
const testcase_sph_legendre<double>
data011[21] =
{
  { 1.2927207364566027, 10, 0, 
	  0.0000000000000000, 0.0 },
  { 0.55288895150522011, 10, 0, 
	  0.15707963267948966, 0.0 },
  { -0.44874428379711329, 10, 0, 
	  0.31415926535897931, 0.0 },
  { -0.25532095827149687, 10, 0, 
	  0.47123889803846897, 0.0 },
  { 0.36625249688013994, 10, 0, 
	  0.62831853071795862, 0.0 },
  { 0.14880806329084206, 10, 0, 
	  0.78539816339744828, 0.0 },
  { -0.33533356797848740, 10, 0, 
	  0.94247779607693793, 0.0 },
  { -0.080639967662335665, 10, 0, 
	  1.0995574287564276, 0.0 },
  { 0.32197986450174521, 10, 0, 
	  1.2566370614359172, 0.0 },
  { 0.025713542103667848, 10, 0, 
	  1.4137166941154069, 0.0 },
  { -0.31813049373736707, 10, 0, 
	  1.5707963267948966, 0.0 },
  { 0.025713542103667528, 10, 0, 
	  1.7278759594743862, 0.0 },
  { 0.32197986450174543, 10, 0, 
	  1.8849555921538759, 0.0 },
  { -0.080639967662335416, 10, 0, 
	  2.0420352248333655, 0.0 },
  { -0.33533356797848757, 10, 0, 
	  2.1991148575128552, 0.0 },
  { 0.14880806329084156, 10, 0, 
	  2.3561944901923448, 0.0 },
  { 0.36625249688013961, 10, 0, 
	  2.5132741228718345, 0.0 },
  { -0.25532095827149576, 10, 0, 
	  2.6703537555513241, 0.0 },
  { -0.44874428379711545, 10, 0, 
	  2.8274333882308138, 0.0 },
  { 0.55288895150522011, 10, 0, 
	  2.9845130209103035, 0.0 },
  { 1.2927207364566027, 10, 0, 
	  3.1415926535897931, 0.0 },
};
const double toler011 = 2.5000000000000020e-13;

// Test data for l=10, m=1.
// max(|f - f_GSL|): 6.2172489379008766e-15 at index 1
// max(|f - f_GSL| / |f_GSL|): 1.0515246092567303e-14
// mean(f - f_GSL): -3.3042351923367698e-17
// variance(f - f_GSL): 5.7319343582953255e-35
// stddev(f - f_GSL): 7.5709539414101082e-18
const testcase_sph_legendre<double>
data012[21] =
{
  { 0.0000000000000000, 10, 1, 
	  0.0000000000000000, 0.0 },
  { -0.74373723919064050, 10, 1, 
	  0.15707963267948966, 0.0 },
  { -0.29035110456209651, 10, 1, 
	  0.31415926535897931, 0.0 },
  { 0.42219282075271530, 10, 1, 
	  0.47123889803846897, 0.0 },
  { 0.17109256898931161, 10, 1, 
	  0.62831853071795862, 0.0 },
  { -0.35583574648544281, 10, 1, 
	  0.78539816339744828, 0.0 },
  { -0.10089212303544023, 10, 1, 
	  0.94247779607693793, 0.0 },
  { 0.32997652649321085, 10, 1, 
	  1.0995574287564276, 0.0 },
  { 0.047416376890032939, 10, 1, 
	  1.2566370614359172, 0.0 },
  { -0.31999356750295660, 10, 1, 
	  1.4137166941154069, 0.0 },
  { -2.0430664782290742e-16, 10, 1, 
	  1.5707963267948966, 0.0 },
  { 0.31999356750295660, 10, 1, 
	  1.7278759594743862, 0.0 },
  { -0.047416376890032544, 10, 1, 
	  1.8849555921538759, 0.0 },
  { -0.32997652649321096, 10, 1, 
	  2.0420352248333655, 0.0 },
  { 0.10089212303543935, 10, 1, 
	  2.1991148575128552, 0.0 },
  { 0.35583574648544292, 10, 1, 
	  2.3561944901923448, 0.0 },
  { -0.17109256898931269, 10, 1, 
	  2.5132741228718345, 0.0 },
  { -0.42219282075271569, 10, 1, 
	  2.6703537555513241, 0.0 },
  { 0.29035110456209601, 10, 1, 
	  2.8274333882308138, 0.0 },
  { 0.74373723919064050, 10, 1, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 10, 1, 
	  3.1415926535897931, 0.0 },
};
const double toler012 = 1.0000000000000008e-12;

// Test data for l=10, m=2.
// max(|f - f_GSL|): 3.3306690738754696e-15 at index 2
// max(|f - f_GSL| / |f_GSL|): 7.9132043938587384e-15
// mean(f - f_GSL): -3.3504944850294902e-16
// variance(f - f_GSL): 5.8935519794618406e-33
// stddev(f - f_GSL): 7.6769472965898634e-17
const testcase_sph_legendre<double>
data013[21] =
{
  { 0.0000000000000000, 10, 2, 
	  0.0000000000000000, 0.0 },
  { 0.34571695599980556, 10, 2, 
	  0.15707963267948966, 0.0 },
  { 0.62485535978198148, 10, 2, 
	  0.31415926535897931, 0.0 },
  { 0.098210039644716252, 10, 2, 
	  0.47123889803846897, 0.0 },
  { -0.41494799233049695, 10, 2, 
	  0.62831853071795862, 0.0 },
  { -0.081698973831472732, 10, 2, 
	  0.78539816339744828, 0.0 },
  { 0.35253132222271277, 10, 2, 
	  0.94247779607693793, 0.0 },
  { 0.049026298555980979, 10, 2, 
	  1.0995574287564276, 0.0 },
  { -0.32791246874130792, 10, 2, 
	  1.2566370614359172, 0.0 },
  { -0.016196782433946871, 10, 2, 
	  1.4137166941154069, 0.0 },
  { 0.32106263400438334, 10, 2, 
	  1.5707963267948966, 0.0 },
  { -0.016196782433946497, 10, 2, 
	  1.7278759594743862, 0.0 },
  { -0.32791246874130803, 10, 2, 
	  1.8849555921538759, 0.0 },
  { 0.049026298555980730, 10, 2, 
	  2.0420352248333655, 0.0 },
  { 0.35253132222271266, 10, 2, 
	  2.1991148575128552, 0.0 },
  { -0.081698973831472121, 10, 2, 
	  2.3561944901923448, 0.0 },
  { -0.41494799233049684, 10, 2, 
	  2.5132741228718345, 0.0 },
  { 0.098210039644715197, 10, 2, 
	  2.6703537555513241, 0.0 },
  { 0.62485535978198081, 10, 2, 
	  2.8274333882308138, 0.0 },
  { 0.34571695599980556, 10, 2, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 10, 2, 
	  3.1415926535897931, 0.0 },
};
const double toler013 = 5.0000000000000039e-13;

// Test data for l=10, m=5.
// max(|f - f_GSL|): 2.8310687127941492e-15 at index 4
// max(|f - f_GSL| / |f_GSL|): 6.7700052018114004e-15
// mean(f - f_GSL): 3.8329128231106644e-17
// variance(f - f_GSL): 7.7128908725222343e-35
// stddev(f - f_GSL): 8.7823065720357509e-18
const testcase_sph_legendre<double>
data014[21] =
{
  { 0.0000000000000000, 10, 5, 
	  0.0000000000000000, 0.0 },
  { -0.0030300124052750873, 10, 5, 
	  0.15707963267948966, 0.0 },
  { -0.070348585248056511, 10, 5, 
	  0.31415926535897931, 0.0 },
  { -0.30055029290703639, 10, 5, 
	  0.47123889803846897, 0.0 },
  { -0.49987818144009138, 10, 5, 
	  0.62831853071795862, 0.0 },
  { -0.28108771757150108, 10, 5, 
	  0.78539816339744828, 0.0 },
  { 0.22068081187249255, 10, 5, 
	  0.94247779607693793, 0.0 },
  { 0.33689502212592121, 10, 5, 
	  1.0995574287564276, 0.0 },
  { -0.086095515520764110, 10, 5, 
	  1.2566370614359172, 0.0 },
  { -0.33935827318511558, 10, 5, 
	  1.4137166941154069, 0.0 },
  { -1.9213014340664546e-16, 10, 5, 
	  1.5707963267948966, 0.0 },
  { 0.33935827318511558, 10, 5, 
	  1.7278759594743862, 0.0 },
  { 0.086095515520764512, 10, 5, 
	  1.8849555921538759, 0.0 },
  { -0.33689502212592104, 10, 5, 
	  2.0420352248333655, 0.0 },
  { -0.22068081187249344, 10, 5, 
	  2.1991148575128552, 0.0 },
  { 0.28108771757150064, 10, 5, 
	  2.3561944901923448, 0.0 },
  { 0.49987818144009155, 10, 5, 
	  2.5132741228718345, 0.0 },
  { 0.30055029290703672, 10, 5, 
	  2.6703537555513241, 0.0 },
  { 0.070348585248056802, 10, 5, 
	  2.8274333882308138, 0.0 },
  { 0.0030300124052750873, 10, 5, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 10, 5, 
	  3.1415926535897931, 0.0 },
};
const double toler014 = 5.0000000000000039e-13;

// Test data for l=10, m=10.
// max(|f - f_GSL|): 2.8865798640254070e-15 at index 10
// max(|f - f_GSL| / |f_GSL|): 5.5362170773729674e-15
// mean(f - f_GSL): -6.6245801611758948e-16
// variance(f - f_GSL): 2.3039657713718755e-32
// stddev(f - f_GSL): 1.5178820017945649e-16
const testcase_sph_legendre<double>
data015[21] =
{
  { 0.0000000000000000, 10, 10, 
	  0.0000000000000000, 0.0 },
  { 4.7624282733345673e-09, 10, 10, 
	  0.15707963267948966, 0.0 },
  { 4.3085156534549315e-06, 10, 10, 
	  0.31415926535897931, 0.0 },
  { 0.00020182347649472387, 10, 10, 
	  0.47123889803846897, 0.0 },
  { 0.0026711045506511706, 10, 10, 
	  0.62831853071795862, 0.0 },
  { 0.016957196623256909, 10, 10, 
	  0.78539816339744828, 0.0 },
  { 0.065174916004990271, 10, 10, 
	  0.94247779607693793, 0.0 },
  { 0.17112476903017845, 10, 10, 
	  1.0995574287564276, 0.0 },
  { 0.32852414199733554, 10, 10, 
	  1.2566370614359172, 0.0 },
  { 0.47940582314838287, 10, 10, 
	  1.4137166941154069, 0.0 },
  { 0.54263029194422152, 10, 10, 
	  1.5707963267948966, 0.0 },
  { 0.47940582314838293, 10, 10, 
	  1.7278759594743862, 0.0 },
  { 0.32852414199733571, 10, 10, 
	  1.8849555921538759, 0.0 },
  { 0.17112476903017851, 10, 10, 
	  2.0420352248333655, 0.0 },
  { 0.065174916004990410, 10, 10, 
	  2.1991148575128552, 0.0 },
  { 0.016957196623256943, 10, 10, 
	  2.3561944901923448, 0.0 },
  { 0.0026711045506511684, 10, 10, 
	  2.5132741228718345, 0.0 },
  { 0.00020182347649472493, 10, 10, 
	  2.6703537555513241, 0.0 },
  { 4.3085156534549772e-06, 10, 10, 
	  2.8274333882308138, 0.0 },
  { 4.7624282733345673e-09, 10, 10, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 10, 10, 
	  3.1415926535897931, 0.0 },
};
const double toler015 = 5.0000000000000039e-13;

// Test data for l=20, m=0.
// max(|f - f_GSL|): 1.2212453270876722e-15 at index 1
// max(|f - f_GSL| / |f_GSL|): 2.0731910827878347e-15
// mean(f - f_GSL): 1.1102230246251565e-16
// variance(f - f_GSL): 6.4711246131411122e-34
// stddev(f - f_GSL): 2.5438405243138007e-17
const testcase_sph_legendre<double>
data016[21] =
{
  { 1.8062879984608917, 20, 0, 
	  0.0000000000000000, 0.0 },
  { -0.58906549291416732, 20, 0, 
	  0.15707963267948966, 0.0 },
  { 0.45624611402342063, 20, 0, 
	  0.31415926535897931, 0.0 },
  { -0.39955402700466724, 20, 0, 
	  0.47123889803846897, 0.0 },
  { 0.36818552901640805, 20, 0, 
	  0.62831853071795862, 0.0 },
  { -0.34873131330857743, 20, 0, 
	  0.78539816339744828, 0.0 },
  { 0.33600882829186468, 20, 0, 
	  0.94247779607693793, 0.0 },
  { -0.32759286308122931, 20, 0, 
	  1.0995574287564276, 0.0 },
  { 0.32222458068091325, 20, 0, 
	  1.2566370614359172, 0.0 },
  { -0.31922731037135965, 20, 0, 
	  1.4137166941154069, 0.0 },
  { 0.31826262039531755, 20, 0, 
	  1.5707963267948966, 0.0 },
  { -0.31922731037135971, 20, 0, 
	  1.7278759594743862, 0.0 },
  { 0.32222458068091342, 20, 0, 
	  1.8849555921538759, 0.0 },
  { -0.32759286308122926, 20, 0, 
	  2.0420352248333655, 0.0 },
  { 0.33600882829186518, 20, 0, 
	  2.1991148575128552, 0.0 },
  { -0.34873131330857782, 20, 0, 
	  2.3561944901923448, 0.0 },
  { 0.36818552901640772, 20, 0, 
	  2.5132741228718345, 0.0 },
  { -0.39955402700466824, 20, 0, 
	  2.6703537555513241, 0.0 },
  { 0.45624611402342408, 20, 0, 
	  2.8274333882308138, 0.0 },
  { -0.58906549291416732, 20, 0, 
	  2.9845130209103035, 0.0 },
  { 1.8062879984608917, 20, 0, 
	  3.1415926535897931, 0.0 },
};
const double toler016 = 2.5000000000000020e-13;

// Test data for l=20, m=1.
// max(|f - f_GSL|): 6.2727600891321345e-15 at index 1
// max(|f - f_GSL| / |f_GSL|): 1.3664592043119372e-14
// mean(f - f_GSL): 2.8416422654096149e-17
// variance(f - f_GSL): 4.2393386513952014e-35
// stddev(f - f_GSL): 6.5110203896126770e-18
const testcase_sph_legendre<double>
data017[21] =
{
  { 0.0000000000000000, 20, 1, 
	  0.0000000000000000, 0.0 },
  { -0.45905213045059046, 20, 1, 
	  0.15707963267948966, 0.0 },
  { 0.31166370423309414, 20, 1, 
	  0.31415926535897931, 0.0 },
  { -0.23278757741246778, 20, 1, 
	  0.47123889803846897, 0.0 },
  { 0.17937240823503983, 20, 1, 
	  0.62831853071795862, 0.0 },
  { -0.13857299972299839, 20, 1, 
	  0.78539816339744828, 0.0 },
  { 0.10495324841927815, 20, 1, 
	  0.94247779607693793, 0.0 },
  { -0.075707774352163665, 20, 1, 
	  1.0995574287564276, 0.0 },
  { 0.049168697683476224, 20, 1, 
	  1.2566370614359172, 0.0 },
  { -0.024216050551253303, 20, 1, 
	  1.4137166941154069, 0.0 },
  { 3.9938443510694310e-16, 20, 1, 
	  1.5707963267948966, 0.0 },
  { 0.024216050551252380, 20, 1, 
	  1.7278759594743862, 0.0 },
  { -0.049168697683475482, 20, 1, 
	  1.8849555921538759, 0.0 },
  { 0.075707774352163346, 20, 1, 
	  2.0420352248333655, 0.0 },
  { -0.10495324841927638, 20, 1, 
	  2.1991148575128552, 0.0 },
  { 0.13857299972299741, 20, 1, 
	  2.3561944901923448, 0.0 },
  { -0.17937240823504172, 20, 1, 
	  2.5132741228718345, 0.0 },
  { 0.23278757741246703, 20, 1, 
	  2.6703537555513241, 0.0 },
  { -0.31166370423309253, 20, 1, 
	  2.8274333882308138, 0.0 },
  { 0.45905213045059046, 20, 1, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 20, 1, 
	  3.1415926535897931, 0.0 },
};
const double toler017 = 1.0000000000000008e-12;

// Test data for l=20, m=2.
// max(|f - f_GSL|): 3.2196467714129540e-15 at index 2
// max(|f - f_GSL| / |f_GSL|): 7.1072009465107655e-15
// mean(f - f_GSL): 9.2518585385429716e-17
// variance(f - f_GSL): 4.4938365369035506e-34
// stddev(f - f_GSL): 2.1198671035948340e-17
const testcase_sph_legendre<double>
data018[21] =
{
  { 0.0000000000000000, 20, 2, 
	  0.0000000000000000, 0.0 },
  { 0.87399805141574205, 20, 2, 
	  0.15707963267948966, 0.0 },
  { -0.55116854080894906, 20, 2, 
	  0.31415926535897931, 0.0 },
  { 0.44520137308557572, 20, 2, 
	  0.47123889803846897, 0.0 },
  { -0.39321637877908278, 20, 2, 
	  0.62831853071795862, 0.0 },
  { 0.36312025711350954, 20, 2, 
	  0.78539816339744828, 0.0 },
  { -0.34427103004873089, 20, 2, 
	  0.94247779607693793, 0.0 },
  { 0.33214917638387642, 20, 2, 
	  1.0995574287564276, 0.0 },
  { -0.32455734448839091, 20, 2, 
	  1.2566370614359172, 0.0 },
  { 0.32036529628513255, 20, 2, 
	  1.4137166941154069, 0.0 },
  { -0.31902310563819986, 20, 2, 
	  1.5707963267948966, 0.0 },
  { 0.32036529628513261, 20, 2, 
	  1.7278759594743862, 0.0 },
  { -0.32455734448839102, 20, 2, 
	  1.8849555921538759, 0.0 },
  { 0.33214917638387659, 20, 2, 
	  2.0420352248333655, 0.0 },
  { -0.34427103004873105, 20, 2, 
	  2.1991148575128552, 0.0 },
  { 0.36312025711350981, 20, 2, 
	  2.3561944901923448, 0.0 },
  { -0.39321637877908228, 20, 2, 
	  2.5132741228718345, 0.0 },
  { 0.44520137308557650, 20, 2, 
	  2.6703537555513241, 0.0 },
  { -0.55116854080895039, 20, 2, 
	  2.8274333882308138, 0.0 },
  { 0.87399805141574205, 20, 2, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 20, 2, 
	  3.1415926535897931, 0.0 },
};
const double toler018 = 5.0000000000000039e-13;

// Test data for l=20, m=5.
// max(|f - f_GSL|): 3.7747582837255322e-15 at index 2
// max(|f - f_GSL| / |f_GSL|): 2.9846361325102863e-14
// mean(f - f_GSL): -1.9825411154020758e-17
// variance(f - f_GSL): 2.0634963689863462e-35
// stddev(f - f_GSL): 4.5425723648460969e-18
const testcase_sph_legendre<double>
data019[21] =
{
  { 0.0000000000000000, 20, 5, 
	  0.0000000000000000, 0.0 },
  { -0.10024848623505046, 20, 5, 
	  0.15707963267948966, 0.0 },
  { -0.68115361075940650, 20, 5, 
	  0.31415926535897931, 0.0 },
  { 0.31774532551156298, 20, 5, 
	  0.47123889803846897, 0.0 },
  { -0.16011868165390658, 20, 5, 
	  0.62831853071795862, 0.0 },
  { 0.085844143304115578, 20, 5, 
	  0.78539816339744828, 0.0 },
  { -0.047467540840863798, 20, 5, 
	  0.94247779607693793, 0.0 },
  { 0.026283575189471796, 20, 5, 
	  1.0995574287564276, 0.0 },
  { -0.013891104052597688, 20, 5, 
	  1.2566370614359172, 0.0 },
  { 0.0059873308239496957, 20, 5, 
	  1.4137166941154069, 0.0 },
  { 3.9355286582083051e-16, 20, 5, 
	  1.5707963267948966, 0.0 },
  { -0.0059873308239503324, 20, 5, 
	  1.7278759594743862, 0.0 },
  { 0.013891104052598547, 20, 5, 
	  1.8849555921538759, 0.0 },
  { -0.026283575189472153, 20, 5, 
	  2.0420352248333655, 0.0 },
  { 0.047467540840865928, 20, 5, 
	  2.1991148575128552, 0.0 },
  { -0.085844143304117007, 20, 5, 
	  2.3561944901923448, 0.0 },
  { 0.16011868165390544, 20, 5, 
	  2.5132741228718345, 0.0 },
  { -0.31774532551156381, 20, 5, 
	  2.6703537555513241, 0.0 },
  { 0.68115361075940484, 20, 5, 
	  2.8274333882308138, 0.0 },
  { 0.10024848623505046, 20, 5, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 20, 5, 
	  3.1415926535897931, 0.0 },
};
const double toler019 = 2.5000000000000015e-12;

// Test data for l=20, m=10.
// max(|f - f_GSL|): 2.3314683517128287e-15 at index 4
// max(|f - f_GSL| / |f_GSL|): 1.0575432165608034e-14
// mean(f - f_GSL): -1.4002922808555493e-16
// variance(f - f_GSL): 1.0294296977074090e-33
// stddev(f - f_GSL): 3.2084726860414586e-17
const testcase_sph_legendre<double>
data020[21] =
{
  { 0.0000000000000000, 20, 10, 
	  0.0000000000000000, 0.0 },
  { 3.0595797603707888e-05, 20, 10, 
	  0.15707963267948966, 0.0 },
  { 0.015924453916396863, 20, 10, 
	  0.31415926535897931, 0.0 },
  { 0.26588079118745744, 20, 10, 
	  0.47123889803846897, 0.0 },
  { 0.54045081420686736, 20, 10, 
	  0.62831853071795862, 0.0 },
  { -0.28215279394285531, 20, 10, 
	  0.78539816339744828, 0.0 },
  { 0.0085297337582239223, 20, 10, 
	  0.94247779607693793, 0.0 },
  { 0.16930127953533738, 20, 10, 
	  1.0995574287564276, 0.0 },
  { -0.27215134048018325, 20, 10, 
	  1.2566370614359172, 0.0 },
  { 0.32456597088029526, 20, 10, 
	  1.4137166941154069, 0.0 },
  { -0.34057893241353715, 20, 10, 
	  1.5707963267948966, 0.0 },
  { 0.32456597088029493, 20, 10, 
	  1.7278759594743862, 0.0 },
  { -0.27215134048018291, 20, 10, 
	  1.8849555921538759, 0.0 },
  { 0.16930127953533702, 20, 10, 
	  2.0420352248333655, 0.0 },
  { 0.0085297337582257438, 20, 10, 
	  2.1991148575128552, 0.0 },
  { -0.28215279394285619, 20, 10, 
	  2.3561944901923448, 0.0 },
  { 0.54045081420686869, 20, 10, 
	  2.5132741228718345, 0.0 },
  { 0.26588079118745828, 20, 10, 
	  2.6703537555513241, 0.0 },
  { 0.015924453916397002, 20, 10, 
	  2.8274333882308138, 0.0 },
  { 3.0595797603707888e-05, 20, 10, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 20, 10, 
	  3.1415926535897931, 0.0 },
};
const double toler020 = 1.0000000000000008e-12;

// Test data for l=20, m=20.
// max(|f - f_GSL|): 2.6645352591003757e-15 at index 10
// max(|f - f_GSL| / |f_GSL|): 4.5133454703584717e-15
// mean(f - f_GSL): -4.3857545834694365e-16
// variance(f - f_GSL): 1.0098292714872165e-32
// stddev(f - f_GSL): 1.0049026179124106e-16
const testcase_sph_legendre<double>
data021[21] =
{
  { 0.0000000000000000, 20, 20, 
	  0.0000000000000000, 0.0 },
  { 4.9264471419250786e-17, 20, 20, 
	  0.15707963267948966, 0.0 },
  { 4.0321091681530921e-11, 20, 20, 
	  0.31415926535897931, 0.0 },
  { 8.8474944184471664e-08, 20, 20, 
	  0.47123889803846897, 0.0 },
  { 1.5497395129387791e-05, 20, 20, 
	  0.62831853071795862, 0.0 },
  { 0.00062457564282984495, 20, 20, 
	  0.78539816339744828, 0.0 },
  { 0.0092265192458967308, 20, 20, 
	  0.94247779607693793, 0.0 },
  { 0.063606673236323297, 20, 20, 
	  1.0995574287564276, 0.0 },
  { 0.23442909509776316, 20, 20, 
	  1.2566370614359172, 0.0 },
  { 0.49921030481087009, 20, 20, 
	  1.4137166941154069, 0.0 },
  { 0.63956545825776223, 20, 20, 
	  1.5707963267948966, 0.0 },
  { 0.49921030481087025, 20, 20, 
	  1.7278759594743862, 0.0 },
  { 0.23442909509776336, 20, 20, 
	  1.8849555921538759, 0.0 },
  { 0.063606673236323324, 20, 20, 
	  2.0420352248333655, 0.0 },
  { 0.0092265192458967742, 20, 20, 
	  2.1991148575128552, 0.0 },
  { 0.00062457564282984766, 20, 20, 
	  2.3561944901923448, 0.0 },
  { 1.5497395129387764e-05, 20, 20, 
	  2.5132741228718345, 0.0 },
  { 8.8474944184472617e-08, 20, 20, 
	  2.6703537555513241, 0.0 },
  { 4.0321091681531780e-11, 20, 20, 
	  2.8274333882308138, 0.0 },
  { 4.9264471419250786e-17, 20, 20, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 20, 20, 
	  3.1415926535897931, 0.0 },
};
const double toler021 = 2.5000000000000020e-13;

// Test data for l=50, m=0.
// max(|f - f_GSL|): 4.8849813083506888e-15 at index 1
// max(|f - f_GSL| / |f_GSL|): 9.1896305557688689e-15
// mean(f - f_GSL): -4.0592529337857286e-16
// variance(f - f_GSL): 8.6507055497352237e-33
// stddev(f - f_GSL): 9.3009169170223341e-17
const testcase_sph_legendre<double>
data022[21] =
{
  { 2.8350175706934717, 50, 0, 
	  0.0000000000000000, 0.0 },
  { 0.53157537495172758, 50, 0, 
	  0.15707963267948966, 0.0 },
  { -0.46056183476300561, 50, 0, 
	  0.31415926535897931, 0.0 },
  { -0.24876032079677909, 50, 0, 
	  0.47123889803846897, 0.0 },
  { 0.36926172901532667, 50, 0, 
	  0.62831853071795862, 0.0 },
  { 0.14571730283563575, 50, 0, 
	  0.78539816339744828, 0.0 },
  { -0.33636199170850750, 50, 0, 
	  0.94247779607693793, 0.0 },
  { -0.079132716267091507, 50, 0, 
	  1.0995574287564276, 0.0 },
  { 0.32232921941301451, 50, 0, 
	  1.2566370614359172, 0.0 },
  { 0.025253991969481544, 50, 0, 
	  1.4137166941154069, 0.0 },
  { -0.31830208724152359, 50, 0, 
	  1.5707963267948966, 0.0 },
  { 0.025253991969479882, 50, 0, 
	  1.7278759594743862, 0.0 },
  { 0.32232921941301479, 50, 0, 
	  1.8849555921538759, 0.0 },
  { -0.079132716267090064, 50, 0, 
	  2.0420352248333655, 0.0 },
  { -0.33636199170850883, 50, 0, 
	  2.1991148575128552, 0.0 },
  { 0.14571730283563347, 50, 0, 
	  2.3561944901923448, 0.0 },
  { 0.36926172901532522, 50, 0, 
	  2.5132741228718345, 0.0 },
  { -0.24876032079677354, 50, 0, 
	  2.6703537555513241, 0.0 },
  { -0.46056183476301255, 50, 0, 
	  2.8274333882308138, 0.0 },
  { 0.53157537495172758, 50, 0, 
	  2.9845130209103035, 0.0 },
  { 2.8350175706934717, 50, 0, 
	  3.1415926535897931, 0.0 },
};
const double toler022 = 5.0000000000000039e-13;

// Test data for l=50, m=1.
// max(|f - f_GSL|): 7.8825834748386114e-15 at index 1
// max(|f - f_GSL| / |f_GSL|): 1.6168319946399610e-14
// mean(f - f_GSL): -8.8223079635391627e-17
// variance(f - f_GSL): 4.0862386846851427e-34
// stddev(f - f_GSL): 2.0214447023564960e-17
const testcase_sph_legendre<double>
data023[21] =
{
  { 0.0000000000000000, 50, 1, 
	  0.0000000000000000, 0.0 },
  { -0.63751752155228247, 50, 1, 
	  0.15707963267948966, 0.0 },
  { -0.32616619317605133, 50, 1, 
	  0.31415926535897931, 0.0 },
  { 0.40649930826162850, 50, 1, 
	  0.47123889803846897, 0.0 },
  { 0.18473991408343635, 50, 1, 
	  0.62831853071795862, 0.0 },
  { -0.35083930302013117, 50, 1, 
	  0.78539816339744828, 0.0 },
  { -0.10755382110947342, 50, 1, 
	  0.94247779607693793, 0.0 },
  { 0.32822568316499900, 50, 1, 
	  1.0995574287564276, 0.0 },
  { 0.050286056609797389, 50, 1, 
	  1.2566370614359172, 0.0 },
  { -0.31935368562159644, 50, 1, 
	  1.4137166941154069, 0.0 },
  { -9.8421602686195843e-16, 50, 1, 
	  1.5707963267948966, 0.0 },
  { 0.31935368562159649, 50, 1, 
	  1.7278759594743862, 0.0 },
  { -0.050286056609795446, 50, 1, 
	  1.8849555921538759, 0.0 },
  { -0.32822568316499923, 50, 1, 
	  2.0420352248333655, 0.0 },
  { 0.10755382110946902, 50, 1, 
	  2.1991148575128552, 0.0 },
  { 0.35083930302013205, 50, 1, 
	  2.3561944901923448, 0.0 },
  { -0.18473991408344057, 50, 1, 
	  2.5132741228718345, 0.0 },
  { -0.40649930826163011, 50, 1, 
	  2.6703537555513241, 0.0 },
  { 0.32616619317604606, 50, 1, 
	  2.8274333882308138, 0.0 },
  { 0.63751752155228247, 50, 1, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 50, 1, 
	  3.1415926535897931, 0.0 },
};
const double toler023 = 1.0000000000000008e-12;

// Test data for l=50, m=2.
// max(|f - f_GSL|): 3.7747582837255322e-15 at index 1
// max(|f - f_GSL| / |f_GSL|): 1.3049193367556654e-14
// mean(f - f_GSL): 2.4038311024250043e-16
// variance(f - f_GSL): 3.0336620837175507e-33
// stddev(f - f_GSL): 5.5078689923758629e-17
const testcase_sph_legendre<double>
data024[21] =
{
  { 0.0000000000000000, 50, 2, 
	  0.0000000000000000, 0.0 },
  { -0.37230261163836259, 50, 2, 
	  0.15707963267948966, 0.0 },
  { 0.50051599680315517, 50, 2, 
	  0.31415926535897931, 0.0 },
  { 0.21724795180329495, 50, 2, 
	  0.47123889803846897, 0.0 },
  { -0.37948127307611107, 50, 2, 
	  0.62831853071795862, 0.0 },
  { -0.13187372121003413, 50, 2, 
	  0.78539816339744828, 0.0 },
  { 0.33959009162400128, 50, 2, 
	  0.94247779607693793, 0.0 },
  { 0.072537503112489563, 50, 2, 
	  1.0995574287564276, 0.0 },
  { -0.32310306941855266, 50, 2, 
	  1.2566370614359172, 0.0 },
  { -0.023259822816436636, 50, 2, 
	  1.4137166941154069, 0.0 },
  { 0.31842698506357275, 50, 2, 
	  1.5707963267948966, 0.0 },
  { -0.023259822816434638, 50, 2, 
	  1.7278759594743862, 0.0 },
  { -0.32310306941855316, 50, 2, 
	  1.8849555921538759, 0.0 },
  { 0.072537503112488411, 50, 2, 
	  2.0420352248333655, 0.0 },
  { 0.33959009162400267, 50, 2, 
	  2.1991148575128552, 0.0 },
  { -0.13187372121003124, 50, 2, 
	  2.3561944901923448, 0.0 },
  { -0.37948127307610924, 50, 2, 
	  2.5132741228718345, 0.0 },
  { 0.21724795180329090, 50, 2, 
	  2.6703537555513241, 0.0 },
  { 0.50051599680316095, 50, 2, 
	  2.8274333882308138, 0.0 },
  { -0.37230261163836259, 50, 2, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 50, 2, 
	  3.1415926535897931, 0.0 },
};
const double toler024 = 1.0000000000000008e-12;

// Test data for l=50, m=5.
// max(|f - f_GSL|): 6.4254157550180935e-15 at index 18
// max(|f - f_GSL| / |f_GSL|): 8.3058098108785765e-14
// mean(f - f_GSL): 3.9419525844577751e-16
// variance(f - f_GSL): 8.1579698435094999e-33
// stddev(f - f_GSL): 9.0321480521022794e-17
const testcase_sph_legendre<double>
data025[21] =
{
  { 0.0000000000000000, 50, 5, 
	  0.0000000000000000, 0.0 },
  { -0.57750385903191603, 50, 5, 
	  0.15707963267948966, 0.0 },
  { 0.077360497065570286, 50, 5, 
	  0.31415926535897931, 0.0 },
  { 0.47707267400540226, 50, 5, 
	  0.47123889803846897, 0.0 },
  { 0.055370615126626811, 50, 5, 
	  0.62831853071795862, 0.0 },
  { -0.37629451847202833, 50, 5, 
	  0.78539816339744828, 0.0 },
  { -0.048042277801963115, 50, 5, 
	  0.94247779607693793, 0.0 },
  { 0.33619379362228718, 50, 5, 
	  1.0995574287564276, 0.0 },
  { 0.025265227185718764, 50, 5, 
	  1.2566370614359172, 0.0 },
  { -0.32083679430964535, 50, 5, 
	  1.4137166941154069, 0.0 },
  { -9.8189201019751726e-16, 50, 5, 
	  1.5707963267948966, 0.0 },
  { 0.32083679430964546, 50, 5, 
	  1.7278759594743862, 0.0 },
  { -0.025265227185716790, 50, 5, 
	  1.8849555921538759, 0.0 },
  { -0.33619379362228730, 50, 5, 
	  2.0420352248333655, 0.0 },
  { 0.048042277801958064, 50, 5, 
	  2.1991148575128552, 0.0 },
  { 0.37629451847202872, 50, 5, 
	  2.3561944901923448, 0.0 },
  { -0.055370615126630517, 50, 5, 
	  2.5132741228718345, 0.0 },
  { -0.47707267400540176, 50, 5, 
	  2.6703537555513241, 0.0 },
  { -0.077360497065588632, 50, 5, 
	  2.8274333882308138, 0.0 },
  { 0.57750385903191603, 50, 5, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 50, 5, 
	  3.1415926535897931, 0.0 },
};
const double toler025 = 5.0000000000000029e-12;

// Test data for l=50, m=10.
// max(|f - f_GSL|): 4.2188474935755949e-15 at index 17
// max(|f - f_GSL| / |f_GSL|): 8.5566462271658482e-15
// mean(f - f_GSL): 2.1378401694418937e-16
// variance(f - f_GSL): 2.3994393097916561e-33
// stddev(f - f_GSL): 4.8984072000923484e-17
const testcase_sph_legendre<double>
data026[21] =
{
  { 0.0000000000000000, 50, 10, 
	  0.0000000000000000, 0.0 },
  { 0.15606941844801256, 50, 10, 
	  0.15707963267948966, 0.0 },
  { -0.53748868836814168, 50, 10, 
	  0.31415926535897931, 0.0 },
  { -0.49304919025183969, 50, 10, 
	  0.47123889803846897, 0.0 },
  { -0.26267582750427920, 50, 10, 
	  0.62831853071795862, 0.0 },
  { 0.22058983666314153, 50, 10, 
	  0.78539816339744828, 0.0 },
  { 0.32936725160671843, 50, 10, 
	  0.94247779607693793, 0.0 },
  { -0.092053311559447959, 50, 10, 
	  1.0995574287564276, 0.0 },
  { -0.32542913495935522, 50, 10, 
	  1.2566370614359172, 0.0 },
  { 0.025673223789103351, 50, 10, 
	  1.4137166941154069, 0.0 },
  { 0.32150019350255743, 50, 10, 
	  1.5707963267948966, 0.0 },
  { 0.025673223789105259, 50, 10, 
	  1.7278759594743862, 0.0 },
  { -0.32542913495935510, 50, 10, 
	  1.8849555921538759, 0.0 },
  { -0.092053311559449028, 50, 10, 
	  2.0420352248333655, 0.0 },
  { 0.32936725160671687, 50, 10, 
	  2.1991148575128552, 0.0 },
  { 0.22058983666314380, 50, 10, 
	  2.3561944901923448, 0.0 },
  { -0.26267582750428364, 50, 10, 
	  2.5132741228718345, 0.0 },
  { -0.49304919025184135, 50, 10, 
	  2.6703537555513241, 0.0 },
  { -0.53748868836814501, 50, 10, 
	  2.8274333882308138, 0.0 },
  { 0.15606941844801256, 50, 10, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 50, 10, 
	  3.1415926535897931, 0.0 },
};
const double toler026 = 5.0000000000000039e-13;

// Test data for l=50, m=20.
// max(|f - f_GSL|): 5.3290705182007514e-15 at index 17
// max(|f - f_GSL| / |f_GSL|): 8.3091988651062939e-15
// mean(f - f_GSL): -6.3705667112909982e-16
// variance(f - f_GSL): 2.1306663117079729e-32
// stddev(f - f_GSL): 1.4596802087128444e-16
const testcase_sph_legendre<double>
data027[21] =
{
  { 0.0000000000000000, 50, 20, 
	  0.0000000000000000, 0.0 },
  { 3.0409598712835887e-07, 50, 20, 
	  0.15707963267948966, 0.0 },
  { 0.030940518122881844, 50, 20, 
	  0.31415926535897931, 0.0 },
  { 0.64134588721659802, 50, 20, 
	  0.47123889803846897, 0.0 },
  { 0.29895244392136594, 50, 20, 
	  0.62831853071795862, 0.0 },
  { 0.25309324781873871, 50, 20, 
	  0.78539816339744828, 0.0 },
  { 0.34368634714931567, 50, 20, 
	  0.94247779607693793, 0.0 },
  { 0.33996764360663945, 50, 20, 
	  1.0995574287564276, 0.0 },
  { 0.12866267745104024, 50, 20, 
	  1.2566370614359172, 0.0 },
  { -0.18201114398922874, 50, 20, 
	  1.4137166941154069, 0.0 },
  { -0.33216683431510857, 50, 20, 
	  1.5707963267948966, 0.0 },
  { -0.18201114398923010, 50, 20, 
	  1.7278759594743862, 0.0 },
  { 0.12866267745103857, 50, 20, 
	  1.8849555921538759, 0.0 },
  { 0.33996764360663895, 50, 20, 
	  2.0420352248333655, 0.0 },
  { 0.34368634714931812, 50, 20, 
	  2.1991148575128552, 0.0 },
  { 0.25309324781874126, 50, 20, 
	  2.3561944901923448, 0.0 },
  { 0.29895244392136405, 50, 20, 
	  2.5132741228718345, 0.0 },
  { 0.64134588721659869, 50, 20, 
	  2.6703537555513241, 0.0 },
  { 0.030940518122882274, 50, 20, 
	  2.8274333882308138, 0.0 },
  { 3.0409598712835887e-07, 50, 20, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 50, 20, 
	  3.1415926535897931, 0.0 },
};
const double toler027 = 5.0000000000000039e-13;

// Test data for l=50, m=50.
// max(|f - f_GSL|): 8.8817841970012523e-16 at index 10
// max(|f - f_GSL| / |f_GSL|): 1.6947090122367552e-15
// mean(f - f_GSL): 8.9876810627650302e-17
// variance(f - f_GSL): 4.2408665715142198e-34
// stddev(f - f_GSL): 2.0593364396120950e-17
const testcase_sph_legendre<double>
data028[21] =
{
  { 0.0000000000000000, 50, 50, 
	  0.0000000000000000, 0.0 },
  { 4.1649039898161316e-41, 50, 50, 
	  0.15707963267948966, 0.0 },
  { 2.5240684647722935e-26, 50, 50, 
	  0.31415926535897931, 0.0 },
  { 5.6927376423967334e-18, 50, 50, 
	  0.47123889803846897, 0.0 },
  { 2.3116239814797222e-12, 50, 50, 
	  0.62831853071795862, 0.0 },
  { 2.3835981241325056e-08, 50, 50, 
	  0.78539816339744828, 0.0 },
  { 1.9992410287270217e-05, 50, 50, 
	  0.94247779607693793, 0.0 },
  { 0.0024947505670829830, 50, 50, 
	  1.0995574287564276, 0.0 },
  { 0.065057774647971231, 50, 50, 
	  1.2566370614359172, 0.0 },
  { 0.43050607056732243, 50, 50, 
	  1.4137166941154069, 0.0 },
  { 0.79980281171531975, 50, 50, 
	  1.5707963267948966, 0.0 },
  { 0.43050607056732287, 50, 50, 
	  1.7278759594743862, 0.0 },
  { 0.065057774647971398, 50, 50, 
	  1.8849555921538759, 0.0 },
  { 0.0024947505670829878, 50, 50, 
	  2.0420352248333655, 0.0 },
  { 1.9992410287270430e-05, 50, 50, 
	  2.1991148575128552, 0.0 },
  { 2.3835981241325311e-08, 50, 50, 
	  2.3561944901923448, 0.0 },
  { 2.3116239814797057e-12, 50, 50, 
	  2.5132741228718345, 0.0 },
  { 5.6927376423968952e-18, 50, 50, 
	  2.6703537555513241, 0.0 },
  { 2.5240684647724192e-26, 50, 50, 
	  2.8274333882308138, 0.0 },
  { 4.1649039898161316e-41, 50, 50, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 50, 50, 
	  3.1415926535897931, 0.0 },
};
const double toler028 = 2.5000000000000020e-13;

// Test data for l=100, m=0.
// max(|f - f_GSL|): 2.2759572004815709e-15 at index 18
// max(|f - f_GSL| / |f_GSL|): 4.9270578369513465e-15
// mean(f - f_GSL): -2.0618427600181479e-16
// variance(f - f_GSL): 2.2318776726956083e-33
// stddev(f - f_GSL): 4.7242752594399153e-17
const testcase_sph_legendre<double>
data029[21] =
{
  { 3.9993839251484076, 100, 0, 
	  0.0000000000000000, 0.0 },
  { -0.60770160285939456, 100, 0, 
	  0.15707963267948966, 0.0 },
  { 0.46193027883954441, 100, 0, 
	  0.31415926535897931, 0.0 },
  { -0.40218718869815234, 100, 0, 
	  0.47123889803846897, 0.0 },
  { 0.36960201406911097, 100, 0, 
	  0.62831853071795862, 0.0 },
  { -0.34953726547378389, 100, 0, 
	  0.78539816339744828, 0.0 },
  { 0.33646959352497730, 100, 0, 
	  0.94247779607693793, 0.0 },
  { -0.32784733067663224, 100, 0, 
	  1.0995574287564276, 0.0 },
  { 0.32235624474047969, 100, 0, 
	  1.2566370614359172, 0.0 },
  { -0.31929330706601350, 100, 0, 
	  1.4137166941154069, 0.0 },
  { 0.31830791662110325, 100, 0, 
	  1.5707963267948966, 0.0 },
  { -0.31929330706601333, 100, 0, 
	  1.7278759594743862, 0.0 },
  { 0.32235624474048036, 100, 0, 
	  1.8849555921538759, 0.0 },
  { -0.32784733067663291, 100, 0, 
	  2.0420352248333655, 0.0 },
  { 0.33646959352498013, 100, 0, 
	  2.1991148575128552, 0.0 },
  { -0.34953726547378589, 100, 0, 
	  2.3561944901923448, 0.0 },
  { 0.36960201406910725, 100, 0, 
	  2.5132741228718345, 0.0 },
  { -0.40218718869815723, 100, 0, 
	  2.6703537555513241, 0.0 },
  { 0.46193027883955923, 100, 0, 
	  2.8274333882308138, 0.0 },
  { -0.60770160285939456, 100, 0, 
	  2.9845130209103035, 0.0 },
  { 3.9993839251484076, 100, 0, 
	  3.1415926535897931, 0.0 },
};
const double toler029 = 2.5000000000000020e-13;

// Test data for l=100, m=1.
// max(|f - f_GSL|): 4.7184478546569153e-15 at index 18
// max(|f - f_GSL| / |f_GSL|): 1.6136152688198031e-14
// mean(f - f_GSL): 1.7347234759767562e-17
// variance(f - f_GSL): 1.5798644075050619e-35
// stddev(f - f_GSL): 3.9747508192401971e-18
const testcase_sph_legendre<double>
data030[21] =
{
  { 0.0000000000000000, 100, 1, 
	  0.0000000000000000, 0.0 },
  { -0.50851949013714159, 100, 1, 
	  0.15707963267948966, 0.0 },
  { 0.33129641402223092, 100, 1, 
	  0.31415926535897931, 0.0 },
  { -0.24390405750942512, 100, 1, 
	  0.47123889803846897, 0.0 },
  { 0.18659755088413388, 100, 1, 
	  0.62831853071795862, 0.0 },
  { -0.14355908970517178, 100, 1, 
	  0.78539816339744828, 0.0 },
  { 0.10844906813251505, 100, 1, 
	  0.94247779607693793, 0.0 },
  { -0.078100088690857675, 100, 1, 
	  1.0995574287564276, 0.0 },
  { 0.050670002998302717, 100, 1, 
	  1.2566370614359172, 0.0 },
  { -0.024941251747138900, 100, 1, 
	  1.4137166941154069, 0.0 },
  { 1.9587949830851608e-15, 100, 1, 
	  1.5707963267948966, 0.0 },
  { 0.024941251747135025, 100, 1, 
	  1.7278759594743862, 0.0 },
  { -0.050670002998298824, 100, 1, 
	  1.8849555921538759, 0.0 },
  { 0.078100088690855773, 100, 1, 
	  2.0420352248333655, 0.0 },
  { -0.10844906813250622, 100, 1, 
	  2.1991148575128552, 0.0 },
  { 0.14355908970516626, 100, 1, 
	  2.3561944901923448, 0.0 },
  { -0.18659755088414104, 100, 1, 
	  2.5132741228718345, 0.0 },
  { 0.24390405750941679, 100, 1, 
	  2.6703537555513241, 0.0 },
  { -0.33129641402221749, 100, 1, 
	  2.8274333882308138, 0.0 },
  { 0.50851949013714159, 100, 1, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 100, 1, 
	  3.1415926535897931, 0.0 },
};
const double toler030 = 1.0000000000000008e-12;

// Test data for l=100, m=2.
// max(|f - f_GSL|): 9.3258734068513149e-15 at index 1
// max(|f - f_GSL| / |f_GSL|): 1.3884756158405121e-14
// mean(f - f_GSL): 1.1049362483174177e-15
// variance(f - f_GSL): 6.4096415924402929e-32
// stddev(f - f_GSL): 2.5317269980075443e-16
const testcase_sph_legendre<double>
data031[21] =
{
  { 0.0000000000000000, 100, 2, 
	  0.0000000000000000, 0.0 },
  { 0.67166274297196848, 100, 2, 
	  0.15707963267948966, 0.0 },
  { -0.48226933687994433, 100, 2, 
	  0.31415926535897931, 0.0 },
  { 0.41175421895715525, 100, 2, 
	  0.47123889803846897, 0.0 },
  { -0.37475021787822776, 100, 2, 
	  0.62831853071795862, 0.0 },
  { 0.35242909383605286, 100, 2, 
	  0.78539816339744828, 0.0 },
  { -0.33807110409159863, 100, 2, 
	  0.94247779607693793, 0.0 },
  { 0.32867180390710077, 100, 2, 
	  1.0995574287564276, 0.0 },
  { -0.32271583790278502, 100, 2, 
	  1.2566370614359172, 0.0 },
  { 0.31940354677687466, 100, 2, 
	  1.4137166941154069, 0.0 },
  { -0.31833943693772526, 100, 2, 
	  1.5707963267948966, 0.0 },
  { 0.31940354677687455, 100, 2, 
	  1.7278759594743862, 0.0 },
  { -0.32271583790278552, 100, 2, 
	  1.8849555921538759, 0.0 },
  { 0.32867180390710116, 100, 2, 
	  2.0420352248333655, 0.0 },
  { -0.33807110409160157, 100, 2, 
	  2.1991148575128552, 0.0 },
  { 0.35242909383605503, 100, 2, 
	  2.3561944901923448, 0.0 },
  { -0.37475021787822438, 100, 2, 
	  2.5132741228718345, 0.0 },
  { 0.41175421895716052, 100, 2, 
	  2.6703537555513241, 0.0 },
  { -0.48226933687995360, 100, 2, 
	  2.8274333882308138, 0.0 },
  { 0.67166274297196848, 100, 2, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 100, 2, 
	  3.1415926535897931, 0.0 },
};
const double toler031 = 1.0000000000000008e-12;

// Test data for l=100, m=5.
// max(|f - f_GSL|): 1.5432100042289676e-14 at index 1
// max(|f - f_GSL| / |f_GSL|): 2.4665959612621893e-13
// mean(f - f_GSL): -8.4885802091131797e-16
// variance(f - f_GSL): 3.7829396832437676e-32
// stddev(f - f_GSL): 1.9449780675482609e-16
const testcase_sph_legendre<double>
data032[21] =
{
  { 0.0000000000000000, 100, 5, 
	  0.0000000000000000, 0.0 },
  { 0.062564361105954577, 100, 5, 
	  0.15707963267948966, 0.0 },
  { 0.14179554455882706, 100, 5, 
	  0.31415926535897931, 0.0 },
  { -0.14356866942905960, 100, 5, 
	  0.47123889803846897, 0.0 },
  { 0.12355483388447824, 100, 5, 
	  0.62831853071795862, 0.0 },
  { -0.10090029999681642, 100, 5, 
	  0.78539816339744828, 0.0 },
  { 0.078905134460235241, 100, 5, 
	  0.94247779607693793, 0.0 },
  { -0.058040182398185071, 100, 5, 
	  1.0995574287564276, 0.0 },
  { 0.038142759389482424, 100, 5, 
	  1.2566370614359172, 0.0 },
  { -0.018906264170660478, 100, 5, 
	  1.4137166941154069, 0.0 },
  { 1.9576303042914504e-15, 100, 5, 
	  1.5707963267948966, 0.0 },
  { 0.018906264170657019, 100, 5, 
	  1.7278759594743862, 0.0 },
  { -0.038142759389478365, 100, 5, 
	  1.8849555921538759, 0.0 },
  { 0.058040182398183086, 100, 5, 
	  2.0420352248333655, 0.0 },
  { -0.078905134460225707, 100, 5, 
	  2.1991148575128552, 0.0 },
  { 0.10090029999681013, 100, 5, 
	  2.3561944901923448, 0.0 },
  { -0.12355483388448550, 100, 5, 
	  2.5132741228718345, 0.0 },
  { 0.14356866942904906, 100, 5, 
	  2.6703537555513241, 0.0 },
  { -0.14179554455879767, 100, 5, 
	  2.8274333882308138, 0.0 },
  { -0.062564361105954577, 100, 5, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 100, 5, 
	  3.1415926535897931, 0.0 },
};
const double toler032 = 2.5000000000000014e-11;

// Test data for l=100, m=10.
// max(|f - f_GSL|): 6.9944050551384862e-15 at index 1
// max(|f - f_GSL| / |f_GSL|): 9.2805170220968737e-15
// mean(f - f_GSL): -9.1725568939268895e-16
// variance(f - f_GSL): 4.4171294985470989e-32
// stddev(f - f_GSL): 2.1016968141354497e-16
const testcase_sph_legendre<double>
data033[21] =
{
  { 0.0000000000000000, 100, 10, 
	  0.0000000000000000, 0.0 },
  { -0.75366545187997991, 100, 10, 
	  0.15707963267948966, 0.0 },
  { -0.35914570017278186, 100, 10, 
	  0.31415926535897931, 0.0 },
  { 0.43480692911578295, 100, 10, 
	  0.47123889803846897, 0.0 },
  { -0.40862111080315500, 100, 10, 
	  0.62831853071795862, 0.0 },
  { 0.37832688692909411, 100, 10, 
	  0.78539816339744828, 0.0 },
  { -0.35484056194773494, 100, 10, 
	  0.94247779607693793, 0.0 },
  { 0.33821981171196341, 100, 10, 
	  1.0995574287564276, 0.0 },
  { -0.32729120767830594, 100, 10, 
	  1.2566370614359172, 0.0 },
  { 0.32110336937091438, 100, 10, 
	  1.4137166941154069, 0.0 },
  { -0.31910064020036194, 100, 10, 
	  1.5707963267948966, 0.0 },
  { 0.32110336937091460, 100, 10, 
	  1.7278759594743862, 0.0 },
  { -0.32729120767830605, 100, 10, 
	  1.8849555921538759, 0.0 },
  { 0.33821981171196364, 100, 10, 
	  2.0420352248333655, 0.0 },
  { -0.35484056194773461, 100, 10, 
	  2.1991148575128552, 0.0 },
  { 0.37832688692909372, 100, 10, 
	  2.3561944901923448, 0.0 },
  { -0.40862111080315755, 100, 10, 
	  2.5132741228718345, 0.0 },
  { 0.43480692911577751, 100, 10, 
	  2.6703537555513241, 0.0 },
  { -0.35914570017276798, 100, 10, 
	  2.8274333882308138, 0.0 },
  { -0.75366545187997991, 100, 10, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 100, 10, 
	  3.1415926535897931, 0.0 },
};
const double toler033 = 5.0000000000000039e-13;

// Test data for l=100, m=20.
// max(|f - f_GSL|): 5.2180482157382357e-15 at index 2
// max(|f - f_GSL| / |f_GSL|): 3.3114331221145530e-14
// mean(f - f_GSL): -1.7066374768419445e-16
// variance(f - f_GSL): 1.5291210256147554e-33
// stddev(f - f_GSL): 3.9103977107383276e-17
const testcase_sph_legendre<double>
data034[21] =
{
  { 0.0000000000000000, 100, 20, 
	  0.0000000000000000, 0.0 },
  { 0.053569660841557079, 100, 20, 
	  0.15707963267948966, 0.0 },
  { 0.57154926874731338, 100, 20, 
	  0.31415926535897931, 0.0 },
  { 0.47536909969585633, 100, 20, 
	  0.47123889803846897, 0.0 },
  { -0.28882554564109575, 100, 20, 
	  0.62831853071795862, 0.0 },
  { 0.020116179014043743, 100, 20, 
	  0.78539816339744828, 0.0 },
  { 0.14752195931707024, 100, 20, 
	  0.94247779607693793, 0.0 },
  { -0.24069428588868366, 100, 20, 
	  1.0995574287564276, 0.0 },
  { 0.29031796025014306, 100, 20, 
	  1.2566370614359172, 0.0 },
  { -0.31437256851143458, 100, 20, 
	  1.4137166941154069, 0.0 },
  { 0.32153954851141792, 100, 20, 
	  1.5707963267948966, 0.0 },
  { -0.31437256851143375, 100, 20, 
	  1.7278759594743862, 0.0 },
  { 0.29031796025014139, 100, 20, 
	  1.8849555921538759, 0.0 },
  { -0.24069428588868241, 100, 20, 
	  2.0420352248333655, 0.0 },
  { 0.14752195931706186, 100, 20, 
	  2.1991148575128552, 0.0 },
  { 0.020116179014049562, 100, 20, 
	  2.3561944901923448, 0.0 },
  { -0.28882554564109075, 100, 20, 
	  2.5132741228718345, 0.0 },
  { 0.47536909969585545, 100, 20, 
	  2.6703537555513241, 0.0 },
  { 0.57154926874732348, 100, 20, 
	  2.8274333882308138, 0.0 },
  { 0.053569660841557079, 100, 20, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 100, 20, 
	  3.1415926535897931, 0.0 },
};
const double toler034 = 2.5000000000000015e-12;

// Test data for l=100, m=50.
// max(|f - f_GSL|): 2.4980018054066022e-15 at index 15
// max(|f - f_GSL| / |f_GSL|): 7.4927901205617944e-15
// mean(f - f_GSL): 1.5662074559583175e-16
// variance(f - f_GSL): 1.2878280424271984e-33
// stddev(f - f_GSL): 3.5886321104666028e-17
const testcase_sph_legendre<double>
data035[21] =
{
  { 0.0000000000000000, 100, 50, 
	  0.0000000000000000, 0.0 },
  { 3.3047910392597822e-21, 100, 50, 
	  0.15707963267948966, 0.0 },
  { 1.0592655372554564e-07, 100, 50, 
	  0.31415926535897931, 0.0 },
  { 0.080418744223952773, 100, 50, 
	  0.47123889803846897, 0.0 },
  { -0.56450600580392973, 100, 50, 
	  0.62831853071795862, 0.0 },
  { 0.33338739844742110, 100, 50, 
	  0.78539816339744828, 0.0 },
  { 0.39741714816514678, 100, 50, 
	  0.94247779607693793, 0.0 },
  { 0.35223993750972243, 100, 50, 
	  1.0995574287564276, 0.0 },
  { 0.17885891940721577, 100, 50, 
	  1.2566370614359172, 0.0 },
  { -0.15341660126461967, 100, 50, 
	  1.4137166941154069, 0.0 },
  { -0.34175924303503102, 100, 50, 
	  1.5707963267948966, 0.0 },
  { -0.15341660126462270, 100, 50, 
	  1.7278759594743862, 0.0 },
  { 0.17885891940721302, 100, 50, 
	  1.8849555921538759, 0.0 },
  { 0.35223993750972227, 100, 50, 
	  2.0420352248333655, 0.0 },
  { 0.39741714816514595, 100, 50, 
	  2.1991148575128552, 0.0 },
  { 0.33338739844741666, 100, 50, 
	  2.3561944901923448, 0.0 },
  { -0.56450600580393095, 100, 50, 
	  2.5132741228718345, 0.0 },
  { 0.080418744223953911, 100, 50, 
	  2.6703537555513241, 0.0 },
  { 1.0592655372554981e-07, 100, 50, 
	  2.8274333882308138, 0.0 },
  { 3.3047910392597822e-21, 100, 50, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 100, 50, 
	  3.1415926535897931, 0.0 },
};
const double toler035 = 5.0000000000000039e-13;

// Test data for l=100, m=100.
// max(|f - f_GSL|): 3.6637359812630166e-15 at index 10
// max(|f - f_GSL| / |f_GSL|): 3.8591350247394187e-15
// mean(f - f_GSL): 2.7412914496899967e-16
// variance(f - f_GSL): 3.9452063763753292e-33
// stddev(f - f_GSL): 6.2810877850698192e-17
const testcase_sph_legendre<double>
data036[21] =
{
  { 0.0000000000000000, 100, 100, 
	  0.0000000000000000, 0.0 },
  { 2.5744136608873899e-81, 100, 100, 
	  0.15707963267948966, 0.0 },
  { 9.4551974868947092e-52, 100, 100, 
	  0.31415926535897931, 0.0 },
  { 4.8096190703397596e-35, 100, 100, 
	  0.47123889803846897, 0.0 },
  { 7.9305393636344023e-24, 100, 100, 
	  0.62831853071795862, 0.0 },
  { 8.4320740610944858e-16, 100, 100, 
	  0.78539816339744828, 0.0 },
  { 5.9319660146026674e-10, 100, 100, 
	  0.94247779607693793, 0.0 },
  { 9.2368225946797243e-06, 100, 100, 
	  1.0995574287564276, 0.0 },
  { 0.0062815489742044095, 100, 100, 
	  1.2566370614359172, 0.0 },
  { 0.27505966018176986, 100, 100, 
	  1.4137166941154069, 0.0 },
  { 0.94936713998764621, 100, 100, 
	  1.5707963267948966, 0.0 },
  { 0.27505966018177036, 100, 100, 
	  1.7278759594743862, 0.0 },
  { 0.0062815489742044433, 100, 100, 
	  1.8849555921538759, 0.0 },
  { 9.2368225946797582e-06, 100, 100, 
	  2.0420352248333655, 0.0 },
  { 5.9319660146027946e-10, 100, 100, 
	  2.1991148575128552, 0.0 },
  { 8.4320740610946652e-16, 100, 100, 
	  2.3561944901923448, 0.0 },
  { 7.9305393636342891e-24, 100, 100, 
	  2.5132741228718345, 0.0 },
  { 4.8096190703400333e-35, 100, 100, 
	  2.6703537555513241, 0.0 },
  { 9.4551974868956498e-52, 100, 100, 
	  2.8274333882308138, 0.0 },
  { 2.5744136608873899e-81, 100, 100, 
	  2.9845130209103035, 0.0 },
  { 0.0000000000000000, 100, 100, 
	  3.1415926535897931, 0.0 },
};
const double toler036 = 2.5000000000000020e-13;

template<typename Ret, unsigned int Num>
  void
  test(const testcase_sph_legendre<Ret> (&data)[Num], Ret toler)
  {
    bool test __attribute__((unused)) = true;
    const Ret eps = std::numeric_limits<Ret>::epsilon();
    Ret max_abs_diff = -Ret(1);
    Ret max_abs_frac = -Ret(1);
    unsigned int num_datum = Num;
    for (unsigned int i = 0; i < num_datum; ++i)
  	 {
	const Ret f = std::tr1::sph_legendre(data[i].l, data[i].m,
		     data[i].theta);
	const Ret f0 = data[i].f0;
	const Ret diff = f - f0;
	if (std::abs(diff) > max_abs_diff)
	  max_abs_diff = std::abs(diff);
	if (std::abs(f0) > Ret(10) * eps
	 && std::abs(f) > Ret(10) * eps)
	  {
	    const Ret frac = diff / f0;
	    if (std::abs(frac) > max_abs_frac)
	      max_abs_frac = std::abs(frac);
	  }
      }
    VERIFY(max_abs_frac < toler);
  }

int
main()
{
  test(data001, toler001);
  test(data002, toler002);
  test(data003, toler003);
  test(data004, toler004);
  test(data005, toler005);
  test(data006, toler006);
  test(data007, toler007);
  test(data008, toler008);
  test(data009, toler009);
  test(data010, toler010);
  test(data011, toler011);
  test(data012, toler012);
  test(data013, toler013);
  test(data014, toler014);
  test(data015, toler015);
  test(data016, toler016);
  test(data017, toler017);
  test(data018, toler018);
  test(data019, toler019);
  test(data020, toler020);
  test(data021, toler021);
  test(data022, toler022);
  test(data023, toler023);
  test(data024, toler024);
  test(data025, toler025);
  test(data026, toler026);
  test(data027, toler027);
  test(data028, toler028);
  test(data029, toler029);
  test(data030, toler030);
  test(data031, toler031);
  test(data032, toler032);
  test(data033, toler033);
  test(data034, toler034);
  test(data035, toler035);
  test(data036, toler036);
  return 0;
}
